/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package presentation.controller;

import java.util.Date;
import java.util.List;
import logic.facade.ProjectFacade;
import logic.facade.TaskFacade;
import vo.ProjectVO;
import vo.TaskVO;


/**
 *
 * @author zergio
 */
public class ControlPanelMain {

   
    public List<ProjectVO> getProjectsByCalendar(int id) {
        return new ProjectFacade().getProjectsByCalendar(id);
    }

    public List<TaskVO> getTasksByCalendar(int id) {
        return new TaskFacade().getTasksByCalendar(id);
    }
    
    public ProjectVO findProject (int projectId){
        return (ProjectVO) new ProjectFacade().find(projectId);
    }
    
    public String createProject(ProjectVO vo) {
        new ProjectFacade().create(vo);
        return "Proyecto creado exitosamente!";
    }

    public boolean createTask(TaskVO task) {
        if (!task.getName().equals("") && task.getStartDate() != null && task.getDeadlineDate() != null && task.getProjectId() > 0) {
            new TaskFacade().create(task);
            return true;
        } else {
            return false;
        }
    }

    public List<TaskVO> getTaskByDate(Date date) {
        return new TaskFacade().getTaskByDate(date);
    }

    public boolean updateTask(TaskVO task) {
        if (!task.getName().equals("") && task.getStartDate() != null && task.getDeadlineDate() != null && task.getProjectId() > 0) {            
            return new TaskFacade().update(task);
        } else {
            return false;
        }
    }

    public boolean deleteTask(int taskId) {
        return new TaskFacade().delete(taskId);
    }
    
    public TaskVO findTask (int taskId){
        return (TaskVO) new TaskFacade().find(taskId);
    }

    public boolean deleteProject(int projectId) {
        return new ProjectFacade().delete(projectId);
    }
}
